package com.woniu.springboot.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ATestController {
	@RequestMapping({"/","/index.html"})
	public String get() {
//		public String get(Model model) {
		/*
		  *  测试模板引擎
		 * model.addAttribute("msg", "测试1"); model.addAttribute("a", "aaa");
		 * model.addAttribute("hello", "<h1>hello</h1>");
		 * model.addAttribute("users", Arrays.asList("zs","ls","www"));
		 */
		return "/login";
	}
	@RequestMapping("/user/login")
	public String login(String username,String password,HttpSession session
			,Model model) {
		//只做简单测试验证拦截
		if("a".equals(username)&&"aaa".equals(password)) {
			//将用户信息存入session中
			session.setAttribute("user", username);
			return "redirect:/main";
		}
		model.addAttribute("msg","用户名密码错误");
		return "login";
	}
}
